import request from '@/utils/request'
import {
  makeQueryParamsSafe
} from '@/utils/kris_utils'

export function getNation(data) { // 获取民族
  return request({
    url: `/v1/basic/nation`,
    method: 'get'
  })
}

export function getMarriage(data) { // 获取婚姻状态
  return request({
    url: `/v1/basic/marriage`,
    method: 'get'
  })
}

export function getSchool(data) { // 获取学校列表
  return request({
    url: `/v1/basic/school${makeQueryParamsSafe(data)}`,
    method: 'get'
  })
}

export function getBank(data) { // 获取银行列表
  return request({
    url: `/v1/basic/bank${makeQueryParamsSafe(data)}`,
    method: 'get'
  })
}

export function getPolitic() { // 获取政治面貌
  return request({
    url: `/v1/basic/politic`,
    method: 'get'
  })
}

export function getAddress(id) { // 获取地址
  return request({
    url: `/v1/basic/address?id=${id}`,
    method: 'get'
  })
}

export function getPosition(params) { // 获取职位
  return request({
    url: `/v1/basic/position`,
    method: 'get',
    params
  })
}

export function getDept(dept_id = '') { // 获取部门
  return request({
    url: `/v1/basic/department?dept_id=${dept_id}`,
    method: 'get'
  })
}

export function getDeptpeople(params) { // 获取部门成员
  return request({
    url: `/v1/basic/user/department`,
    method: 'get',
    params
  })
}

export function verificationcodeSend(data) { // 发送验证码
  return request({
    url: `/v1/verificationcode/send`,
    method: 'post',
    data
  })
}

export function getDormitory(queryParams) { // 获取宿舍
  return request({
    url: `/v1/basic/dormitory${makeQueryParamsSafe(queryParams)}`,
    method: 'get'
  })
}

export function getRoomUser(params) { // 获取宿舍
  return request({
    url: `/v1/basic/room/user`,
    method: 'get',
    params
  })
}

export function getEducation(params) {
  return request({
    url: `/v1/basic/education`,
    method: 'GET',
    params
  })
}

export function userReminder(params) {
  return request({
    url: `/v1/user/reminder`,
    method: 'GET',
    params
  })
}

// 获取公司的详情
export function companyInfo(id) {
  return request({
    url: `/v1/basic/company/${id}`,
    method: 'GET'
  })
}

// 修改公司信息
export function updateCompanyInfo(data) {
  return request({
    url: '/v1/basic/company',
    method: 'PUT',
    params: data
  })
}

// 动态搜索获取字段
export function getSearchFields(params) {
  return request({
    url: '/v1/basic/fields',
    method: 'GET',
    params
  })
}

// 文件上传
export function uploadFile(data) {
  return request({
    url: '/v1/upload/file',
    method: 'POST',
    data
  })
}

// 根据父级部门id获取父部门以及子部门的成员
export function getUserByDepartmentParentId(params) {
  return request({
    url: `/v1/department/highest`,
    method: 'GET',
    params
  })
}
